package comm

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

func Success(c *gin.Context, data interface{}) {
	if data != nil {
		c.JSON(http.StatusOK, gin.H{
			"code": 0,
			"data": data,
		})
	} else {
		c.JSON(http.StatusOK, gin.H{
			"code": 0,
		})
	}
}

func Fail(c *gin.Context, code int, message interface{}) {
	c.JSON(http.StatusOK, gin.H{
		"code": code,
		"message": message,
	})
}